package com.hd.batch.quartz.batch.job.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.ItemReadListener;
import org.springframework.batch.core.SkipListener;
import org.springframework.stereotype.Component;

/**
 * <h3>partitionjob</h3>
 * <p>listener.UserSkipListener</p>
 *
 * @author : hduong
 * @version : 1.0
 * @date : 2020-09-10 17:34
 **/
@Component@Slf4j
public class UserSkipListener implements SkipListener, ItemReadListener {

    public static int ERROR_TOTAL = 0;
    public static int SKIP_TOTAL = 0;

    @Override
    public void beforeRead() {

    }

    @Override
    public void afterRead(Object o) {

    }

    @Override
    public void onReadError(Exception e) {
        ERROR_TOTAL++;
        log.info("读取错误: {}", e);
    }

    @Override
    public void onSkipInRead(Throwable throwable) {

    }

    @Override
    public void onSkipInWrite(Object o, Throwable throwable) {

    }

    @Override
    public void onSkipInProcess(Object o, Throwable throwable) {
        SKIP_TOTAL++;
        log.info("跳过处理: {}, 原因: {}", o, throwable);
    }
}
